Gio.DesktopAppInfo.set_desktop_env('GNOME');
- global.grab_dbus_service();
shellDBusService = new ShellDBus.GnomeShell();
// Force a connection now; dbus.js will do this internally
// if we use its name acquisition stuff but we aren't right
_init: function() {
DBus.session.exportObject('/org/freedesktop/Notifications', this);
- this._everAcquiredName = false;
- DBus.session.acquire_name('org.freedesktop.Notifications',
- // We pass MANY_INSTANCES so that if
- // notification-daemon is running, we'll
- // get queued behind it and then get the
- // name after killing it below
- DBus.MANY_INSTANCES,
- Lang.bind(this, this._acquiredName),
- Lang.bind(this, this._lostName));
-
this._sources = {};
this._senderToPid = {};
this._notifications = {};
Lang.bind(this, this._onFocusAppChanged));
},
- _acquiredName: function() {
- this._everAcquiredName = true;
- },
-
- _lostName: function() {
- if (this._everAcquiredName)
- log('Lost name org.freedesktop.Notifications!');
- else if (GLib.getenv('GNOME_SHELL_NO_REPLACE'))
- log('Failed to acquire org.freedesktop.Notifications');
- else {
- log('Failed to acquire org.freedesktop.Notifications; trying again');
- Util.killall('notification-daemon');
- Util.killall('notify-osd');
- }
- },
-
_iconForNotificationData: function(icon, hints, size) {
let textureCache = St.TextureCache.get_default();
#include "st.h"
#include "shell-a11y.h"
+#define SHELL_DBUS_SERVICE "org.gnome.Shell"
+#define MAGNIFIER_DBUS_SERVICE "org.gnome.Magnifier"
+
static void gnome_shell_plugin_dispose (GObject *object);
static void gnome_shell_plugin_finalize (GObject *object);
+static void gnome_shell_plugin_early_initialize (MetaPlugin *plugin);
static void gnome_shell_plugin_start (MetaPlugin *plugin);
static void gnome_shell_plugin_minimize (MetaPlugin *plugin,
MetaWindowActor *actor);
gobject_class->dispose = gnome_shell_plugin_dispose;
gobject_class->finalize = gnome_shell_plugin_finalize;
+ plugin_class->early_initialize = gnome_shell_plugin_early_initialize;
plugin_class->start = gnome_shell_plugin_start;
plugin_class->map = gnome_shell_plugin_map;
plugin_class->minimize = gnome_shell_plugin_minimize;
/* Intentionally empty to discard message */
}
+static void
+gnome_shell_plugin_early_initialize (MetaPlugin *plugin)
+{
+ GError *error = NULL;
+ DBusGConnection *session;
+ DBusGProxy *bus;
+ guint32 request_name_result;
+
+ /** TODO:
+ * In the future we should use GDBus for this. However, in
+ * order to do that, we need to port all of the JavaScript
+ * code. Otherwise, the name will be claimed on the wrong
+ * connection.
+ */
+ session = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+
+ bus = dbus_g_proxy_new_for_name (session,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS);
+
+ if (!dbus_g_proxy_call (bus, "RequestName", &error,
+ G_TYPE_STRING, SHELL_DBUS_SERVICE,
+ G_TYPE_UINT, 0,
+ G_TYPE_INVALID,
+ G_TYPE_UINT, &request_name_result,
+ G_TYPE_INVALID))
+ {
+ g_print ("failed to acquire org.gnome.Shell: %s\n", error->message);
+ /* If we somehow got started again, it's not an error to be running
+ * already. So just exit 0.
+ */
+ exit (0);
+ }
+
+ /* Also grab org.gnome.Panel to replace any existing panel process,
+ * unless a special environment variable is passed. The environment
+ * variable is used by the gnome-shell (no --replace) launcher in
+ * Xephyr */
+ if (!dbus_g_proxy_call (bus, "RequestName", &error, G_TYPE_STRING,
+ "org.gnome.Panel", G_TYPE_UINT,
+ DBUS_NAME_FLAG_REPLACE_EXISTING | DBUS_NAME_FLAG_DO_NOT_QUEUE,
+ G_TYPE_INVALID, G_TYPE_UINT,
+ &request_name_result, G_TYPE_INVALID))
+ {
+ g_print ("failed to acquire org.gnome.Panel: %s\n", error->message);
+ exit (1);
+ }
+
+ /* ...and the org.gnome.Magnifier service.
+ */
+ if (!dbus_g_proxy_call (bus, "RequestName", &error,
+ G_TYPE_STRING, MAGNIFIER_DBUS_SERVICE,
+ G_TYPE_UINT, 0,
+ G_TYPE_INVALID,
+ G_TYPE_UINT, &request_name_result,
+ G_TYPE_INVALID))
+ {
+ g_print ("failed to acquire %s: %s\n", MAGNIFIER_DBUS_SERVICE, error->message);
+ /* Failing to acquire the magnifer service is not fatal. Log the error,
+ * but keep going. */
+ }
+
+ /* ...and the org.freedesktop.Notifications service.
+ */
+ if (!dbus_g_proxy_call (bus, "RequestName", &error,
+ G_TYPE_STRING, "org.freedesktop.Notifications",
+ G_TYPE_UINT, DBUS_NAME_FLAG_REPLACE_EXISTING | DBUS_NAME_FLAG_DO_NOT_QUEUE,
+ G_TYPE_INVALID,
+ G_TYPE_UINT, &request_name_result,
+ G_TYPE_INVALID))
+ {
+ g_print ("failed to acquire org.freedesktop.Notifications: %s\n", error->message);
+ }
+
+ g_object_unref (bus);
+}
+
static void
gnome_shell_plugin_start (MetaPlugin *plugin)
{
#endif
#include "shell-jsapi-compat-private.h"
-#define SHELL_DBUS_SERVICE "org.gnome.Shell"
-#define MAGNIFIER_DBUS_SERVICE "org.gnome.Magnifier"
-
static void grab_notify (GtkWidget *widget, gboolean is_grab, gpointer user_data);
struct _ShellGlobal {
gjs_context_maybe_gc (global->js_context);
}
-void
-shell_global_grab_dbus_service (ShellGlobal *global)
-{
- GError *error = NULL;
- DBusGConnection *session;
- DBusGProxy *bus;
- guint32 request_name_result;
-
- session = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
-
- bus = dbus_g_proxy_new_for_name (session,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS);
-
- if (!dbus_g_proxy_call (bus, "RequestName", &error,
- G_TYPE_STRING, SHELL_DBUS_SERVICE,
- G_TYPE_UINT, 0,
- G_TYPE_INVALID,
- G_TYPE_UINT, &request_name_result,
- G_TYPE_INVALID))
- {
- g_print ("failed to acquire org.gnome.Shell: %s\n", error->message);
- /* If we somehow got started again, it's not an error to be running
- * already. So just exit 0.
- */
- exit (0);
- }
-
- /* Also grab org.gnome.Panel to replace any existing panel process,
- * unless a special environment variable is passed. The environment
- * variable is used by the gnome-shell (no --replace) launcher in
- * Xephyr */
- if (!g_getenv ("GNOME_SHELL_NO_REPLACE"))
- {
- if (!dbus_g_proxy_call (bus, "RequestName", &error, G_TYPE_STRING,
- "org.gnome.Panel", G_TYPE_UINT,
- DBUS_NAME_FLAG_REPLACE_EXISTING | DBUS_NAME_FLAG_DO_NOT_QUEUE,
- G_TYPE_INVALID, G_TYPE_UINT,
- &request_name_result, G_TYPE_INVALID))
- {
- g_print ("failed to acquire org.gnome.Panel: %s\n", error->message);
- exit (1);
- }
- }
-
- /* ...and the org.gnome.Magnifier service.
- */
- if (!dbus_g_proxy_call (bus, "RequestName", &error,
- G_TYPE_STRING, MAGNIFIER_DBUS_SERVICE,
- G_TYPE_UINT, 0,
- G_TYPE_INVALID,
- G_TYPE_UINT, &request_name_result,
- G_TYPE_INVALID))
- {
- g_print ("failed to acquire %s: %s\n", MAGNIFIER_DBUS_SERVICE, error->message);
- /* Failing to acquire the magnifer service is not fatal. Log the error,
- * but keep going. */
- }
- g_object_unref (bus);
-}
-
static void
grab_notify (GtkWidget *widget, gboolean was_grabbed, gpointer user_data)
{
const char *directory,
GError **error);
-void shell_global_grab_dbus_service (ShellGlobal *global);
-
typedef enum {
SHELL_STAGE_INPUT_MODE_NONREACTIVE,
SHELL_STAGE_INPUT_MODE_NORMAL,